package com.ddzh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddzh.pojo.ExportDataVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ExportDataMapper extends BaseMapper<ExportDataVo> {


    //当天新增
    @Select("select count(*) from member where create_date = date_format(now(),'%Y-%m-%d')")
    Integer findBycreateDate();

    //总会员数
    @Select("select count(name) from member")
    Integer findAllTotal();

    //本周新增
    @Select("SELECT count(*) FROM  member WHERE YEARWEEK(create_date) = YEARWEEK(now())")
    Integer findMemberByWeek();

    //本月新增
    @Select("SELECT count(*) FROM member where date_format(create_date,'%Y-%m') = date_format(curdate() , '%Y-%m')")
    Integer findMemberByMonth();

    //今日预约数
    @Select("select count(*) from order_t where order_date = date_format(now(),'%Y-%m-%d')")
    Integer findOrderByDay();

    //本月到诊数
    @Select("SELECT count(*) FROM order_t where date_format(order_date,'%Y-%m') = date_format(curdate() , '%Y-%m')")
    Integer findOrderByMonth();

    //本周到诊数
    @Select("SELECT count(*) FROM  order_t WHERE YEARWEEK(order_date) = YEARWEEK(now())")
    Integer findOrderByWeek();

    //本月预约
    @Select("SELECT count(*) FROM order_t where date_format(order_date,'%Y-%m') = date_format(curdate() , '%Y-%m') and order_status = 1")
    Integer findOrderExamineByMonth();

    //本周预约
    @Select("SELECT count(*) FROM  order_t WHERE YEARWEEK(order_date) = YEARWEEK(now()) and order_status = 1")
    Integer findOrderExamineByWeek();


    //本日预约
    @Select("select count(*) from order_t  where order_status = 1 and order_date = date_format(now(),'%Y-%m-%d')")
    Integer findOrderExamineByDay();





    //热门
    @Select("SELECT COUNT(o.SETMEAL_ID) AS count,s.name, s.remark\n" +
            "FROM setmeal_t s , order_t o \n" +
            "WHERE s.ID = o.SETMEAL_ID\n" +
            "group by s.id \n" +
            "order by count desc")
     List<Map<String, Object>> findHotSetMeal();


}
